<?php
/**
* @copyright (C) 2003 - 2008 SystN International Pty Ltd.
* @license http://www.systn.com
* SystN is Free Software
*/

Class Dirver{
	//连接数据库
	function DBLink($dba=''){
		$this -> LinkID = ($dba['pconnect'] == 1)? sqlite_popen($dba['dbname'], $dba['dbhost']) : sqlite_open($dba['dbname'], $dba['dbhost']);
		if (!$this->LinkID){ return 1; }
		
		sqlite_busy_timeout($this -> LinkID,30);	//超时
		return $this->LinkID;
	}
	
	
	//查询语句
	function query($query,$limit) {
		$this -> nums ++;
		$this-> Lists .= $query.'&nbsp;&nbsp;<font>'.date('Y-m-d H:i:s')."</font><br>";
		//检测如果有限制数据集则处理
		if($limit>0){
			$query = $query.' LIMIT '.$limit;
		}
		
		return @sqlite_query($query,$this->LinkID);
	}
	
	
	//返回数组资料
	function fetch_array($query) {
		return @sqlite_fetch_array($query, SQLITE_ASSOC);
	}
	
	
	//取得返回列的数目
	function num_rows($query){
		return @sqlite_num_rows($query);
	}
	
	
	//返回最后一次使用 INSERT 指令的 ID
	function insert_id(){
		return @sqlite_last_insert_rowid($this->LinkID);
	}
	
	
	//关闭当前数据库连接
	function close(){
		return @sqlite_close($this->LinkID);
	}
	
	
	//检测sqlite版本
	function version(){
		return @sqlite_libversion();
	}
	
	
	//查询语句数
	function sql_num(){
		return $this -> nums;
	}
	
	//查询语句列表
	function sql_debug(){
		return $this-> Lists;
	}
	
	
}
?>